package com.example.exam.util;

import com.example.exam.entity.Choice;
import com.example.exam.entity.QuestionAnswer;
import com.example.exam.vo.QuestionAnswerVO;

import java.util.List;

/**
 * @author shishuqian
 * date 2021/6/29
 * time 15:52
 **/
public class QuestionUtil {

    public static QuestionAnswerVO questionAnswerTransVO(QuestionAnswer questionAnswer){
        QuestionAnswerVO vo = new QuestionAnswerVO();
        vo.setId(questionAnswer.getId());
        vo.setExamPaperId(questionAnswer.getExamPaperId());
        vo.setQuestionId(questionAnswer.getQuestionId());
        vo.setUserId(questionAnswer.getUserId());
        vo.setQuestionType(questionAnswer.getQuestionType());
        vo.setQuestionScore(questionAnswer.getQuestionScore());
        vo.setUserScore(questionAnswer.getUserScore());
        vo.setUserAnswer(questionAnswer.getUserAnswer());
        vo.setDoRight(questionAnswer.getDoRight());
        return vo;
    }

    public static boolean setRight(List<Choice> choices){
        boolean answerNo = true; //是否设置了正确答案:true没设置   false:设置了
        for (Choice choice1: choices){
            if (choice1.getRightAnswer()!=null){
                answerNo = false;
                break;
            }
        }
        return answerNo;
    }
}
